package com.student.demo.controller;

import com.student.demo.dto.StudentInfoDTO;
import com.student.demo.config.Result;
import com.student.demo.entity.StudentInfo;
import com.student.demo.service.IStudentInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("/stuInfo")
public class StudentInfoController {
    @Resource
    private IStudentInfoService studentInfoService;

    @PostMapping("/insert")
    public Result<?> insert(@RequestBody(required = false) StudentInfo studentInfo) {
        return studentInfoService.insert(studentInfo);
    }

    @DeleteMapping("/delInfo/{id}")
    public Result<?> delById(@PathVariable("id") Long id) {
        return studentInfoService.delInfo(id);
    }

    @PutMapping("/updateInfo")
    public Result<?> updateInfo(@RequestBody(required = false) StudentInfo studentInfo) {
        return studentInfoService.updateInfo(studentInfo);
    }

    @PostMapping("/listPage")
    public Result<?> listPage(@RequestBody(required = false) StudentInfoDTO studentInfoDTO) {
        return studentInfoService.listPage(studentInfoDTO);
    }
}
